package co.uniquindio.software.medisys.logica;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import co.uniquindio.software.medisys.entidades.Rips;

public class GestorRips {

	EntityManagerFactory emf = Persistence
	.createEntityManagerFactory("MedisysPU");
	
	public void guardarRips(Rips rip) {
		EntityManager em = emf.createEntityManager();
		EntityTransaction et = em.getTransaction();
		et.begin();
		em.persist(rip);
		et.commit();
	}
	
	public void modificarRips(Rips rip) {

		EntityManager em = emf.createEntityManager();
		EntityTransaction et = em.getTransaction();
		et.begin();
		em.merge(rip);
		et.commit();
	}
	
	public Rips obtenerRip(int idRip){
		EntityManager em = emf.createEntityManager();
		return em.find(Rips.class, idRip);
	}
}
